// pages/test/test.js
Page({
  data: {
    Provinces:[],
    items:[{text:"zjd",children:[{text:'123'}]},{text:"zjd",children:[{text:'123'}]}],
    majorName:[],
    CollageName: [],
    mainActiveIndex: 0,
    activeId: null

  },
  onClickNav(event) {
    let self = this;
    let pro = this.data.Provinces;

    const aimProvince = self.data.Provinces[event.detail.index].text
    // console.log(aimProvince);
      wx.cloud.callFunction({
        name:"getCollageByProvince",
        data:{
          provincesName:aimProvince
        },
        success(res){
          let str = []
          for (let i = 0; i < res.result.data.length; i++) {
            str.push({
              text:res.result.data[i].name,
              parma:"null"
            })
          }
          pro[event.detail.index].children = str
          self.setData({
            Provinces:pro
          })
          console.log(self.data.Provinces[event.detail.index].children);
         
        }
        
      })
    
  
  },

  onClickItem({ detail = {} }) {
    const activeId = this.data.activeId === detail.id ? null : detail.id;

    this.setData({ activeId });
  },
  /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function (options) {
      let self = this;
      wx.cloud.callFunction({
        name:'getCollageName',
        data:{},
        success(res){
          self.setData({
            CollageName:res.result.data.map(x => x={text:x.name})
          })
          // console.log(res.result.data);
        }
      })
      wx.cloud.callFunction({
        name:'getMajor',
        data:'',
        success(res){

          self.setData({
            majorName:res.result.data.map(x => x=x.name)
          })
          // console.log(self.data.majorName);
        }
      })
      wx.cloud.callFunction({
        name:"getProvince",
        data:'',
        success(res){
          self.setData({
            Provinces:res.result.data
          })
          console.log(res);
        }
      })

    },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})